{
 "cells": [
  {
   "metadata": {
    "ExecutionIndicator": {
     "show": true
    },
    "tags": []
   },
   "cell_type": "code",
   "outputs": [],
   "execution_count": null,
   "source": [
    "import os\n",
    "if __name__ == \"__main__\":\n",
    "    wqwen_convertor = f\"\"\"\n",
    "        cd /mnt/workspace/myproject/llm-learning/Pai-Megatron-Patch/toolkits/model_checkpoints_convertor/qwen\n",
    "        sh hf2mcore_qwen2.5_convertor.sh \\\n",
    "        0.5B \\\n",
    "        /mnt/workspace/qwen-ckpts/Qwen2.5-0.5B \\\n",
    "        /mnt/workspace/qwen-ckpts/Qwen2.5-0.5B-hf-to-mcore-te-tp1-pp1  \\\n",
    "        1  \\\n",
    "        1  \\\n",
    "        bf16 \\\n",
    "        true \\\n",
    "        false\n",
    "          \"\"\"\n",
    "    with os.popen(wqwen_convertor, 'r') as file:\n",
    "        output = file.read()\n",
    "        print(output)\n"
   ],
   "id": "06f6917c-c67f-4c59-9161-2285331ece86"
  },
  {
   "metadata": {
    "execution": {
     "iopub.execute_input": "2024-12-19T07:32:39.985647Z",
     "iopub.status.busy": "2024-12-19T07:32:39.985184Z",
     "iopub.status.idle": "2024-12-19T07:32:39.990678Z",
     "shell.execute_reply": "2024-12-19T07:32:39.990263Z",
     "shell.execute_reply.started": "2024-12-19T07:32:39.985629Z"
    },
    "tags": [],
    "jupyter": {
     "is_executing": true
    }
   },
   "cell_type": "code",
   "source": [
    "import torch\n",
    "torch.cuda.is_available()\n"
   ],
   "id": "dd938755-4a83-4d5e-83ff-53ca23eb39af",
   "outputs": [],
   "execution_count": null
  },
  {
   "metadata": {
    "tags": [],
    "jupyter": {
     "is_executing": true
    }
   },
   "cell_type": "code",
   "source": [
    "import torch\n",
    "def check_pytorch_cuda_versions():\n",
    "    print(f\"PyTorch版本: {torch.__version__}\")\n",
    "    print(f\"PyTorch CUDA版本: {torch.version.cuda}\")\n",
    "    print(f\"CUDA是否可用: {torch.cuda.is_available()}\")\n",
    "    print(f\"GPU数量: {torch.cuda.device_count()}\")\n",
    "\n",
    "    if torch.cuda.is_available():\n",
    "        print(f\"当前GPU名称: {torch.cuda.get_device_name(0)}\")\n",
    "        print(f\"cuDNN版本: {torch.backends.cudnn.version()}\")\n",
    "    else:\n",
    "        print(\"没有检测到CUDA设备\")\n",
    "if __name__ == \"__main__\":\n",
    "    check_pytorch_cuda_versions()"
   ],
   "id": "a4e5a409-fa2d-46d4-acd7-c8d3c51b815c",
   "outputs": [],
   "execution_count": null
  },
  {
   "metadata": {
    "ExecutionIndicator": {
     "show": true
    },
    "tags": []
   },
   "cell_type": "code",
   "outputs": [],
   "execution_count": null,
   "source": "python -c \"from accelerate import Accelerator; print(Accelerator.is_main_process)\"",
   "id": "562ec6fb-c00c-435d-8900-aae4b40bd153"
  },
  {
   "metadata": {
    "ExecutionIndicator": {
     "show": true
    },
    "execution": {
     "iopub.execute_input": "2024-12-30T16:06:06.514312Z",
     "iopub.status.busy": "2024-12-30T16:06:06.513827Z",
     "iopub.status.idle": "2024-12-30T16:06:06.535899Z",
     "shell.execute_reply": "2024-12-30T16:06:06.535316Z",
     "shell.execute_reply.started": "2024-12-30T16:06:06.514297Z"
    },
    "tags": []
   },
   "cell_type": "code",
   "outputs": [
    {
     "ename": "AttributeError",
     "evalue": "'str' object has no attribute 'location'",
     "output_type": "error",
     "traceback": [
      "\u001B[0;31m---------------------------------------------------------------------------\u001B[0m",
      "\u001B[0;31mAttributeError\u001B[0m                            Traceback (most recent call last)",
      "Cell \u001B[0;32mIn[13], line 9\u001B[0m\n\u001B[1;32m      6\u001B[0m packages \u001B[38;5;241m=\u001B[39m pip_misc\u001B[38;5;241m.\u001B[39mget_pip_version()\n\u001B[1;32m      8\u001B[0m \u001B[38;5;66;03m# 按照安装时间对软件包进行倒序排序\u001B[39;00m\n\u001B[0;32m----> 9\u001B[0m packages_sorted \u001B[38;5;241m=\u001B[39m \u001B[38;5;28;43msorted\u001B[39;49m\u001B[43m(\u001B[49m\u001B[43mpackages\u001B[49m\u001B[43m,\u001B[49m\u001B[43m \u001B[49m\u001B[43mkey\u001B[49m\u001B[38;5;241;43m=\u001B[39;49m\u001B[38;5;28;43;01mlambda\u001B[39;49;00m\u001B[43m \u001B[49m\u001B[43mpackage\u001B[49m\u001B[43m:\u001B[49m\u001B[43m \u001B[49m\u001B[43mos\u001B[49m\u001B[38;5;241;43m.\u001B[39;49m\u001B[43mpath\u001B[49m\u001B[38;5;241;43m.\u001B[39;49m\u001B[43mgetctime\u001B[49m\u001B[43m(\u001B[49m\u001B[43mpackage\u001B[49m\u001B[38;5;241;43m.\u001B[39;49m\u001B[43mlocation\u001B[49m\u001B[43m)\u001B[49m\u001B[43m,\u001B[49m\u001B[43m \u001B[49m\u001B[43mreverse\u001B[49m\u001B[38;5;241;43m=\u001B[39;49m\u001B[38;5;28;43;01mTrue\u001B[39;49;00m\u001B[43m)\u001B[49m\n\u001B[1;32m     11\u001B[0m \u001B[38;5;66;03m# 遍历每个软件包，并输出其名称、版本及安装日期和时间\u001B[39;00m\n\u001B[1;32m     12\u001B[0m \u001B[38;5;28;01mfor\u001B[39;00m package \u001B[38;5;129;01min\u001B[39;00m packages_sorted:\n",
      "Cell \u001B[0;32mIn[13], line 9\u001B[0m, in \u001B[0;36m<lambda>\u001B[0;34m(package)\u001B[0m\n\u001B[1;32m      6\u001B[0m packages \u001B[38;5;241m=\u001B[39m pip_misc\u001B[38;5;241m.\u001B[39mget_pip_version()\n\u001B[1;32m      8\u001B[0m \u001B[38;5;66;03m# 按照安装时间对软件包进行倒序排序\u001B[39;00m\n\u001B[0;32m----> 9\u001B[0m packages_sorted \u001B[38;5;241m=\u001B[39m \u001B[38;5;28msorted\u001B[39m(packages, key\u001B[38;5;241m=\u001B[39m\u001B[38;5;28;01mlambda\u001B[39;00m package: os\u001B[38;5;241m.\u001B[39mpath\u001B[38;5;241m.\u001B[39mgetctime(\u001B[43mpackage\u001B[49m\u001B[38;5;241;43m.\u001B[39;49m\u001B[43mlocation\u001B[49m), reverse\u001B[38;5;241m=\u001B[39m\u001B[38;5;28;01mTrue\u001B[39;00m)\n\u001B[1;32m     11\u001B[0m \u001B[38;5;66;03m# 遍历每个软件包，并输出其名称、版本及安装日期和时间\u001B[39;00m\n\u001B[1;32m     12\u001B[0m \u001B[38;5;28;01mfor\u001B[39;00m package \u001B[38;5;129;01min\u001B[39;00m packages_sorted:\n",
      "\u001B[0;31mAttributeError\u001B[0m: 'str' object has no attribute 'location'"
     ]
    }
   ],
   "execution_count": 13,
   "source": [
    "import pip._internal.utils.misc as pip_misc\n",
    "import os\n",
    "import time\n",
    "\n",
    "# 获取已安装的所有软件包\n",
    "packages = pip_misc.get_pip_version()\n",
    "\n",
    "# 按照安装时间对软件包进行倒序排序\n",
    "packages_sorted = sorted(packages, key=lambda package: os.path.getctime(package.location), reverse=True)\n",
    "\n",
    "# 遍历每个软件包，并输出其名称、版本及安装日期和时间\n",
    "for package in packages_sorted:\n",
    "    package_name = package.project_name\n",
    "    package_version = package.version\n",
    "    package_location = package.location\n",
    "    install_time = time.ctime(os.path.getctime(package_location))\n",
    "    print(f\"软件包 {package_name} 版本 {package_version} 的安装时间：{install_time}\")"
   ],
   "id": "fe8d7a16-d275-425d-a8e9-8cb2268fed7c"
  },
  {
   "metadata": {},
   "cell_type": "code",
   "outputs": [],
   "execution_count": null,
   "source": "",
   "id": "a06a27ff63c54c87"
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.10.12"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
